<?php echo $this->partial('header.phtml', array('urlbase'=>$this->urlbase)); ?>  

<!-- Main -->
<div class="wrapper style1">

    <div class="container">
        <div class="row 200%">
            <?php if($this->blog['BLO_ID'] > 0){ ?>
            <div class="8u important(collapse)" id="content">
                <article id="main">
                    <header>
                        <h2><?php echo $this->blog['BLO_NOM']; ?></h2>
                        <div class="blg-data">
                            Publicado em <?php echo Datetools::amd_dma($this->blog['BLO_DAT']); ?>
                        </div>
                    </header>
                    <p>
                        <?php echo $this->blog['BLO_TXT']; ?>
                    </p>
                </article>
            </div>
            <?php } else { ?>
                
                
                <div class="8u important(collapse)" id="content">
                    <?php foreach($this->blogs as $blog){ ?>
                    <article id="main">
                        <header>
                            <h2><?php echo $blog['BLO_NOM']; ?></h2>
                            <div class="blg-data">
                                Publicado em <?php echo Datetools::amd_dma($blog['BLO_DAT']); ?>
                            </div>
                        </header>
                        <p>
                            <?php echo $blog['BLO_TXT']; ?>
                        </p>
                        
                        <div class="fbComments">
                            <?php 
                                $url = $_SERVER['HTTP_HOST'].''.$this->urlbase.'/'.$this->controller.'/index/id/'.$blog['BLO_ID'];
                                $pos = strpos($url, 'www.');
                                if ($pos === false) $url = 'http://www.'.$url;
                                else $url = 'http://'.$url; 
                                
                            ?>
                            
                            <div id="fb-root"></div>

                            <script>(function(d, s, id) {
                              var js, fjs = d.getElementsByTagName(s)[0];
                              if (d.getElementById(id)) return;
                              js = d.createElement(s); js.id = id;
                              js.src = "//connect.facebook.net/pt_BR/sdk.js#xfbml=1&appId=688243397900389&version=v2.0";
                              fjs.parentNode.insertBefore(js, fjs);
                            }(document, 'script', 'facebook-jssdk'));</script>

                            <iframe src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode($url); ?>&amp;width&amp;layout=standard&amp;action=like&amp;show_faces=false&amp;share=true&amp;height=35&amp;appId=688243397900389" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100%; height:35px;" allowTransparency="true"></iframe>

                            <div class="fb-comments" data-href="<?php echo $url; ?>" data-width="100%" data-numposts="5" data-colorscheme="light"></div>
                        </div>
                        
                    </article>
                    <?php } ?>
                
                    <?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
                    
                </div>
            
            <?php } ?>
            
            <div class="4u" id="sidebar">

                <h3>Dicas por Categorias</h3>
                <?php foreach($this->cats as $cats){
                    $query = 'SELECT SQL_CACHE BLO_ID FROM ST_BLOG WHERE CTB_ID = '.$cats['CTB_ID'].' and BLO_STA = 1';
                    $blog = $this->db->fetchRow($query);
                    if($blog['BLO_ID'] > 0){
                ?>
                <section>
                    <a href="<?php echo $this->urlbase.'/'.$this->controller.'/index/cat/'.$cats['CTB_ID']; ?>">&rsaquo; <?php echo $cats['CTB_NOM']?></a>
                </section>
                <?php } } ?>
                <section>
                    <a href="<?php echo $this->urlbase.'/'.$this->controller; ?>">&rsaquo; Ver todas</a>
                </section>
                <br>
                
                <h3>Dicas do Mês</h3>
                <?php foreach($this->meses as $mes){ ?>
                    <section>
                        <a href="<?php echo $this->urlbase.'/'.$this->controller.'/index/ano/'.$mes['ano'].'/mes/'.$mes['mes']; ?>">&rsaquo; <?php echo ucfirst(Datetools::texto_Mes($mes['mes'])).' ('.$mes['ano'].')';?></a>
                    </section>
                <?php } ?>
                
                <br>
                
            </div>
        </div>
    </div>
</div>

<?php echo $this->partial('footer.phtml', array('urlbase'=>$this->urlbase)); ?>